package com.info3k.client.tabs;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Composite;
import com.info3k.client.Info3K;
import com.info3k.client.Info3KService;
import com.info3k.client.Info3KServiceAsync;
import com.info3k.client.enums.TabTypes;

public class Tab extends Composite{
	
	private TabTypes type;
	
	private Info3K info3k;
	
	Info3KServiceAsync infoService = GWT.create(Info3KService.class);
	
	public void refresh(){}
	public void render(){}
	
	public void setType(TabTypes type) {
		this.type = type;
	}
	public TabTypes getType() {
		return type;
	}
	public void setInfo3k(Info3K info3k) {
		this.info3k = info3k;
	}
	public Info3K getInfo3k() {
		return info3k;
	}
	
	public static Tab getTabByType(TabTypes type){
		Tab tab = null;
		if(type.equals(TabTypes.CATEGORIES_LEFT)){
			tab = new Categories();
		} else if(type.equals(TabTypes.LATEST_ADDRESSES_LEFT) || type.equals(TabTypes.LATEST_ADDRESSES_TOP)){
			return new LatestAddresses(5);
		} else if(type.equals(TabTypes.LATEST_EVENTS_LEFT) || type.equals(TabTypes.LATEST_EVENTS_TOP)){
			return new LatestEvents(5);
		} else if(type.equals(TabTypes.LATEST_LOCATIONS_LEFT) || type.equals(TabTypes.LATEST_LOCATIONS_TOP)){
			return new LatestLocations(5);
		} else if(type.equals(TabTypes.LATEST_USERS_LEFT) || type.equals(TabTypes.LATEST_USERS_TOP)){
			return new LatestUsers(5);
		}
		
		if(tab!=null) tab.setType(type);
		
		return tab;
	}
}
